﻿@{    
    //page title
    ViewBag.Title = T("Admin.Configuration.Shipping.Providers").Text;
}
<div class="section-header">
    <div class="title">
        <img src="@Url.Content("~/Administration/Content/images/ico-configuration.png")" alt="" />
        @T("Admin.Configuration.Shipping.Providers")
    </div>
</div>
<table class="adminContent">
    <tr>
        <td>
            <div id="shippingproviders-grid"></div>

            <script>
                $(document).ready(function () {
                    $("#shippingproviders-grid").kendoGrid({
                        dataSource: {
                            type: "json",
                            transport: {
                                read: {
                                    url: "@Html.Raw(Url.Action("Providers", "Shipping"))",
                                    type: "POST",
                                    dataType: "json"
                                },
                                update: {
                                    url: "@Html.Raw(Url.Action("ProviderUpdate", "Shipping"))",
                                    type: "POST",
                                    dataType: "json"
                                }
                            },
                            schema: {
                                data: "Data",
                                total: "Total",
                                errors: "Errors",
                                model: {
                                    id: "SystemName",
                                    fields: {
                                        FriendlyName: { editable: false, type: "string" },
                                        SystemName: { editable: false, type: "string" },
                                        LogoUrl: { editable: false, type: "string" },
                                        DisplayOrder: { editable: true, type: "number" },
                                        IsActive: { editable: true, type: "boolean" }
                                    }
                                }
                            },
                            requestEnd: function (e) {
                                if (e.type == "update") {
                                    this.read();
                                }
                            },
                            error: function (e) {
                                display_kendoui_grid_error(e);
                                // Cancel the changes
                                this.cancelChanges();
                            },
                            serverPaging: true,
                            serverFiltering: true,
                            serverSorting: true
                        },
                        pageable: {
                            refresh: true,
                            numeric: false,
                            previousNext: false,
                            info: false
                        },
                        editable: {
                            confirmation: false,
                            mode: "inline"
                        },
                        scrollable: false,
                        columns: [{
                            field: "FriendlyName",
                            title: "@T("Admin.Configuration.Payment.Methods.Fields.FriendlyName")",
                            width: 250
                        }, {
                            field: "SystemName",
                            title: "@T("Admin.Configuration.Payment.Methods.Fields.SystemName")",
                            width: 250
                        }, {
                            field: "LogoUrl",
                            title: "@T("Admin.Configuration.Payment.Methods.Fields.Logo")",
                            width: 100,
                            template: '<img src="#=LogoUrl#" />'
                        }, {
                            field: "DisplayOrder",
                            title: "@T("Admin.Configuration.Shipping.Providers.Fields.DisplayOrder")",
                            //integer format
                            format: "{0:0}",
                            width: 100
                        }, {
                            field: "IsActive",
                            title: "@T("Admin.Configuration.Shipping.Providers.Fields.IsActive")",
                            width: 100,
                            headerAttributes: { style: "text-align:center" },
                            attributes: { style: "text-align:center" },
                            template: '<img src="@Url.Content("~/Administration/Content/images/")active-#=IsActive#.gif" />'
                        }, {
                            field: "SystemName",
                            title: "@T("Admin.Configuration.Shipping.Providers.Configure")",
                            width: 150,
                            template: '<a href="ConfigureProvider?systemName=#=SystemName#">@T("Admin.Configuration.Shipping.Providers.Configure")</a>'
                        }, {
                            command: {name: "edit", text: "@T("Admin.Common.Edit")"},
                            title: "@T("Admin.Common.Edit")",
                            width: 150
                        }]
                    });
                });
            </script>
        </td>
    </tr>
</table>
